<template>
  <div class="sumBox">
    <FormPanel :list="topFilterList" :cols="1" :collapse="false" :isSubmitBtn="false" @filterChange="changeHandle"></FormPanel>
  </div>
</template>
<script>
export default {
  props: ['getdata'],
  data() {
    return {
      topFilterList: this.createdFrom()
    };
  },
  watch: {
    getdata: {
      handler: function(newval, oldVal) {
        if (newval.type == 'add') {
          this.topFilterList.map((item, key) => {
            item.disabled = false;
          });
        } else if (newval.type == 'emit') {
          this.initData();
          this.topFilterList.map((item, key) => {
            item.disabled = false;
          });
        } else {
          this.topFilterList.forEach(x => {
            x.initialValue = '';
          });
          this.topFilterList.map((item, key) => {
            item.disabled = true;
          });
        }
        console.log(newval);
      },
      deep: true
    }
  },
  created() {},
  methods: {
    createdFrom() {
      return [
        {
          type: 'INPUT',
          label: '不含税金额',
          fieldName: 'NET_AMOUNT',
          initialValue: '',
          itemList: [],
          disabled: true,
          style: {
            'min-width': '100px'
          }
        },
        {
          type: 'INPUT',
          label: '税额',
          fieldName: 'NET_AMOUNT',
          initialValue: '',
          itemList: [],
          disabled: true,
          style: {
            'min-width': '100px'
          }
        },
        {
          type: 'INPUT',
          label: '结算金额',
          fieldName: 'WORK_ORDER_NUMBER',
          initialValue: '',
          itemList: [],
          disabled: true,
          style: {
            'min-width': '100px'
          }
        },
        {
          type: 'INPUT',
          label: '去零金额',
          fieldName: 'SUB_OBB_AMOUNT',
          initialValue: '',
          itemList: [],
          disabled: true,
          style: {
            'min-width': '100px'
          }
        },
        {
          type: 'INPUT',
          label: '收款金额',
          fieldName: 'RECEIVE_AMOUNT',
          initialValue: '',
          itemList: [],
          disabled: true,
          style: {
            'min-width': '100px'
          }
        }
      ];
    },
    changeHandle(val) {},
    initData() {
      this.topFilterList.forEach(x => {
        x.initialValue = this.getdata[x.fieldName];
      });
    }
  }
};
</script>
<style lang="less" scope>
.sumBox {
  clear: both;
  width: 100%;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  padding-top: 10px;
  padding-right: 20px;
  box-sizing: border-box;
}
</style>
